<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    .content {
      width: 500px;
      height: 500px;
      background-image: url('../img/bg.jpg');
      background-size: cover;
      position: relative;
    }
    .wuxing-slot {
      display: block;
      width: 50px;
      height: 50px;
      border: 2px solid red;
      border-radius: 50%;
      color: white;
      line-height: 50px;
      text-align: center;
      font-size: 30px;
      position: absolute;
    }
    .jin-span {
      top: 30px;
      left: 227px;
    }
    .tu-span {
      top: 150px;
      left: 60px;
    }
    .mu-span {
      top: 150px;
      right: 50px;
    }
    .shui-span {
      top: 335px;
      right: 115px;
    }
    .huo-span {
      top: 335px;
      left: 125px;
    }
    .btns {
      width: 80px;
      height: 40px;
      margin: 10px;
      background-color: #56a5f1;
      color: white;
      border: none;
      border-radius: 6px;
      outline: none;
      cursor: pointer;
      font-size: 20px;
    }
    .websit {
      width: 300px;
      height: 300px;
      background-color: #CCC;
    }
  </style>
</head>
<body>
  <div id="app">
    <div class="content">
      <!-- 插槽 -->
      <span v-for="(item, index) in wuxingList" :key="index"
        :class="['wuxing-slot',wuxingList[index].class+'-span']" @click="pickSlot(index)">
        {{wuxingList[index].txt}}
      </span>
    </div>
    <!-- 元素 -->
    <button v-for="(item, index) in wuxingList" :key="index"
      class="btns" @click="pickEl(index)">{{item.name}}
    </button>
    <!-- 点击按钮，更换网站风格 -->
    <div class="websit" :style="{backgroundColor: thems}"></div>
    <button @click="changeThems('blue')">blue</button>
    <button @click="changeThems('pink')">pink</button>
    <button @click="changeThems('green')">green</button>
  </div>
  <script src="../js/vue.js"></script>
  <script>
    let vm = new Vue({
      el: '#app',
      data: {
        wuxingList: [
          {
            name: '金',
            class: 'jin',
            txt: ''
          },{
            name: '木',
            class: 'mu',
            txt: ''
          },{
            name: '水',
            class: 'shui',
            txt: ''
          },{
            name: '火',
            class: 'huo',
            txt: ''
          },{
            name: '土',
            class: 'tu',
            txt: ''
          }
        ],
        // 当前选中的元素
        activeEl: 0,
        thems: 'gray'
      },
      methods: {
        pickEl(index) {
          // console.log('当前选择的元素',this.wuxingList[index].name)
          this.activeEl = index
        },
        pickSlot(index) {
          // console.log('插槽对应的元素',this.wuxingList[index].name)
          if(index == this.activeEl) {
            this.wuxingList[index].txt = this.wuxingList[index].name
          }
        },
        changeThems(thems) {
          this.thems = thems;
        }
      },
    })
  </script>
</body>
</html>